package com.yunxiao.cloud.job.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunxiao.cloud.common.util.DateUtil;
import com.yunxiao.cloud.job.entity.JobLogQueryInfo;
import com.yunxiao.cloud.job.entity.ScheduleJobLog;
import com.yunxiao.cloud.job.mapper.ScheduleJobLogMapper;
import com.yunxiao.cloud.job.service.ScheduleJobLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 定时任务日志 服务实现类
 * </p>
 *
 * @author yunxiao
 * @since 2020-01-09
 */
@Service("scheduleJobLogService")
public class ScheduleJobLogServiceImpl extends ServiceImpl<ScheduleJobLogMapper, ScheduleJobLog> implements ScheduleJobLogService {

    @Resource
    private ScheduleJobLogMapper scheduleJobLogMapper;

    @Override
    public int insert(ScheduleJobLog record) {
        return scheduleJobLogMapper.insert(record);
    }

    @Override
    public void deleteByTime(Date date) {
        //定时删除日志记录
    }

    @Override
    public List<ScheduleJobLog> queryJobLogs(JobLogQueryInfo info) {
        String date = DateUtil.format(info.getDate());
        info.setDate(date);
        return scheduleJobLogMapper.queryJobLogs(info);
    }
}
